package parttern.iterator;

import java.util.ArrayList;
import java.util.List;

public class IteratorImpl<T> implements Iterator<T> {

    private List<T> list = new ArrayList<>();
    private int cursor = 0;


    public IteratorImpl(List<T> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        return cursor != list.size();
    }

    @Override
    public T next() {
        return hasNext() ? list.get(cursor++) : null;
    }
}
